function log(){
	var user = document.getElementById("user").value;
  	var pass = document.getElementById("pass").value;
  	if(user == "admin"){
	  	if(pass == "1234"){
	 		window.location="listado_articulos.html";  
	  	}else{
	 		document.getElementById("mensaje").value = "Usuario y/o password incorrecto";
	  	}
  	}
}

function buscarSolicitudesPendientes(div){
	var tbody = document.getElementById(div);
	
	if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}
    else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
    xmlhttp.open("GET","BuscarSolicitudesPendientes",false);
    xmlhttp.send(null);
    if (xmlhttp.readyState==4 && xmlhttp.status==200){
    	tbody.innerHTML=xmlhttp.responseText;
    }
}

function buscarArticulos(div){
	var tbody = document.getElementById(div);
	
	if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}
    else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
    xmlhttp.open("GET","BuscarArticulos",false);
    xmlhttp.send(null);
    if (xmlhttp.readyState==4 && xmlhttp.status==200){
    	tbody.innerHTML=xmlhttp.responseText;
    }
}

function buscarModulos(div){
	var tbody = document.getElementById(div);
	
	if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}
    else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
    xmlhttp.open("GET","BuscarModulos",false);
    xmlhttp.send(null);
    if (xmlhttp.readyState==4 && xmlhttp.status==200){
    	tbody.innerHTML=xmlhttp.responseText;
    }
}

function buscarOrdenes(div){
	var tbody = document.getElementById(div);
	
	if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}
    else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
    xmlhttp.open("GET","BuscarOrdenes",false);
    xmlhttp.send(null);
    if (xmlhttp.readyState==4 && xmlhttp.status==200){
    	tbody.innerHTML=xmlhttp.responseText;
    }
}

function editar(id){
	document.getElementById("div_editar").style.display = "block";
	var tbody = document.getElementById("div_editar");
	
	if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}
    else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
    xmlhttp.open("GET","EditarModulo?idModulo="+id,false);
    xmlhttp.send(null);
    if (xmlhttp.readyState==4 && xmlhttp.status==200){
    	tbody.innerHTML=xmlhttp.responseText;
    }
	
}

function quitar(){
	var elSel = document.getElementById("servicios_agregados");
	var i;
	for (i = elSel.length - 1; i>=0; i--){
		if (elSel.options[i].selected){
			elSel.remove(i);
		}
	}
}

function agregar(){
	var origenSel = document.getElementById("lista_servicios");
	var destinoSel = document.getElementById("servicios_agregados");
	var elOptNew = document.createElement('option');
	var i;
	var repetido = 0;
	elOptNew.value = "";
	elOptNew.text = "";
	for (i = origenSel.length - 1; i>=0; i--){
		if (origenSel.options[i].selected){
			elOptNew.value = origenSel.options[i].value;
			elOptNew.text = origenSel.options[i].text;
		}
	}
	
	for (i = destinoSel.length - 1; i>=0; i--){
		if (elOptNew.value == destinoSel.options[i].value){
			repetido = 1;
		}
	}
	if(repetido == 0){
		try{
			destinoSel.add(elOptNew, null); // standards compliant; doesn't work in IE
		}catch(ex){
			destinoSel.add(elOptNew); // IE only
		}
	}
}